var express = require('express');
var app = express();

// logs
var morgan = require('morgan');
app.use(morgan('dev'));

// mongodb
var mongo = require('mongodb');
var monk = require('monk');
var db = monk("localhost:27017/mdmtest1");
app.use(function(req,res,next){
	req.db = db;
	next();
});

//==========router
// test
var router_test = require('./router/test.js');
app.use('/test', router_test);

// check user-pwd match 
var router_auth = require('./router/auth.js');
app.use('/user/auth',router_auth);

// bind device--user
var router_bind = require('./router/bind.js');
app.use('/device/bind',router_bind);

// check app is legal
var router_appCheck = require('./router/appCheck.js');
app.use('/app/check',router_appCheck);

// register device
var router_deviceReg = require('./router/deviceReg.js');
app.use('/device/register',router_deviceReg);

//==========router


//
app.listen(8080);
console.log('express start at 8080');